package com.yangchuang.openpicture.controller;


import com.yangchuang.openpicture.communication.ResponseMessage;
import com.yangchuang.openpicture.dto.EmailVerifyCodeDTO;
import com.yangchuang.openpicture.service.EmailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/email")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "邮箱服务", description = "提供与邮箱相关的各类服务，例如发送验证码、邮件通知等。")
public class EmailController {
    private  final EmailService emailService;

    @Operation(summary = "获取邮箱验证码", description = "根据邮箱地址发送验证码，用于注册或登录验证")
    @PostMapping("/send-verify-code")
    public ResponseMessage<String> getEmailVerifyCode(@Valid @RequestBody EmailVerifyCodeDTO emailVerifyCodeDTO){
        log.info("用户获取验证码");
        emailService.sendVerifyCode(emailVerifyCodeDTO.getEmail());
        return ResponseMessage.success(null);
    }
}
